<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
<HEAD>
  <style>
    body {
      font-size: 11px;
      font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
    }

    .favicon {
      height:16px;
      width:16px;
    }

    .favicon img {
      height:16px;
      width:16px;
    }

    .site-view { height:48px; }
    .head-site { width:48px; float: left; clear: left; }
    .body-site { }
    .first-site

  </style>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script src="./core/event.js"></script>
<script>

function OnError()
{
  this.setAttribute("src", "arrow-left.jpg");
  
}

function CreateView(info)
{
  // http://mamba.ru/favicon.ico
  var div      = document.createElement('div');
  div.setAttribute("class", "site-view" )
  var headSite = document.createElement('div');
  headSite.setAttribute("class", "head-site" )
  var bodySite = document.createElement('div');
  bodySite.setAttribute("class", "body-site" )
  div.appendChild(headSite);
  div.appendChild(bodySite);

  var faviconDiv = document.createElement('div');
  faviconDiv.setAttribute("class", "favicon");
  var faviconImg = document.createElement('img');
  Event.add(faviconImg, 'error', OnError)
  faviconImg.setAttribute("src", "http://" + info[0] + "/favicon.ico");
  faviconDiv.appendChild(faviconImg);
  headSite.appendChild(faviconDiv);

  var firstSite = document.createElement('div');
  firstSite.setAttribute("class", "first-site" );
  firstSite.appendChild( document.createTextNode(info[0]));
  Event.add( firstSite, "click", function(){
    launcher.exec( "siteonline", {
      site: info[0]
    });
  });
  bodySite.appendChild(firstSite);
  return div;
}


function SiteView(ownerNode, siteInfo)
{
  this.ownerNode = ownerNode;
  this.siteInfo = siteInfo;
  this.div = CreateView(siteInfo);
  ownerNode.appendChild(this.div);
}




function OnLoad() { try{

  window.incomeSites = window.parent.parent.incomeSites;
  window.comet = window.parent.parent.comet;
  window.launcher = window.parent.parent.launcher;

  var views = {};
  var own = document.getElementById("main");
  for ( var i =0; i < incomeSites.length; i++ )
    views[ incomeSites[i][0] ] = new SiteView(own, incomeSites[i]);

  
  // alert( JSON.stringify( incomeSites ) )
}catch(e){ alert(e.message); } }

Event.add(window, 'load', OnLoad)
</script>
</HEAD>
<BODY>
<div id = "main">
  <h1>WHOSONLINE</h1>
</div>
</BODY>
</HTML>
